/**
 *******************************************************************************
 * @file    MDR12065_adcui.c
 * @author  Milandr Application Team
 * @version V0.2.0
 * @date    10/04/2026
 * @brief   This file contains all the ADCUI firmware functions.
 *******************************************************************************
 * <br><br>
 *
 * THE PRESENT FIRMWARE IS FOR GUIDANCE ONLY. IT AIMS AT PROVIDING CUSTOMERS
 * WITH CODING INFORMATION REGARDING MILANDR'S PRODUCTS IN ORDER TO FACILITATE
 * THE USE AND SAVE TIME. MILANDR SHALL NOT BE HELD LIABLE FOR ANY
 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES RESULTING
 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR A USE MADE BY CUSTOMERS OF THE
 * CODING INFORMATION CONTAINED HEREIN IN THEIR PRODUCTS.
 *
 * <h2><center>&copy; COPYRIGHT 2026 Milandr</center></h2>
 *******************************************************************************
 */

/* Includes ------------------------------------------------------------------*/
#include "MDR12065_adcui.h"

/** @addtogroup MDR12065_StdPeriph_Driver MDR12065 Standard Peripheral Driver
 * @{
 */

/** @defgroup ADCUI ADCUI
 * @{
 */

/** @defgroup ADCUI_Private_Defines ADCUI Private Defines
 * @{
 */

#define IS_ADCUI_CCAL_GAIN(GAIN) ((GAIN) <= 0xFFFF)

/** @} */ /* End of the group ADCUI_Private_Defines */

/** @defgroup ADCUI_Exported_Functions ADCUI Exported Functions
 * @{
 */

/**
 * @brief  Deinitialize the ADCUI peripheral registers to their default reset values.
 * @param  None.
 * @return None.
 */
void ADCUI_DeInit(void)
{
    MDR_ADCUI->CTRL1 = 0;
    MDR_ADCUI->CTRL2 = 0xFFFFFF;

    MDR_ADCUI->F0CTR  = 0;
    MDR_ADCUI->F0AC   = 0;
    MDR_ADCUI->F0STAT = (ADCUI_F0STAT_F0IF_OVR | ADCUI_F0STAT_C3IF_OVR);
    MDR_ADCUI->F0MASK = 0;

    MDR_ADCUI->F1CTR  = 0;
    MDR_ADCUI->F1STAT = ADCUI_FxSTAT_FxIF_OVR;
    MDR_ADCUI->F1MASK = 0;

    MDR_ADCUI->F2CTR  = 0;
    MDR_ADCUI->F2STAT = ADCUI_FxSTAT_FxIF_OVR;
    MDR_ADCUI->F2MASK = 0;

    MDR_ADCUI->CCAL1 = 0;
    MDR_ADCUI->CCAL2 = 0;
    MDR_ADCUI->CCAL3 = 0;
    MDR_ADCUI->CCAL4 = 0;

    MDR_ADCUI->MSC       = 0;
    MDR_ADCUI->FILTERCFG = (0x802 << ADCUI_FILTERCFG_CHPF_COEFF_Pos);
    MDR_ADCUI->CLKPHASE1 = (0x200 << ADCUI_CLKPHASE1_I0PHASE_Pos) |
                           (0x200 << ADCUI_CLKPHASE1_I1PHASE_Pos) |
                           (0x200 << ADCUI_CLKPHASE1_I2PHASE_Pos);
    MDR_ADCUI->CLKPHASE2 = (0x200 << ADCUI_CLKPHASE2_I3PHASE_Pos);
}

/**
 * @brief  Fill each ADCUI_InitStruct member with its default value.
 * @param  ADCUI_InitStruct: The pointer to the @ref ADCUI_InitTypeDef structure
 *         which will be initialized.
 * @return None.
 */
void ADCUI_StructInit(ADCUI_InitTypeDef* ADCUI_InitStruct)
{
    ADCUI_InitStruct->ADCUI_DataResol      = ADCUI_DATA_RESOL_16BIT;
    ADCUI_InitStruct->ADCUI_VRefConfig     = ADCUI_REFERENCE_VOLTAGE_EXTERNAL;
    ADCUI_InitStruct->ADCUI_ClockFrequency = ADCUI_CLK_FREQUENCY_4MHz;
    ADCUI_InitStruct->ADCUI_ChopperPeriod  = ADCUI_CHOPPER_PERIOD_256;
    ADCUI_InitStruct->ADCUI_Divider        = ADCUI_OVERSAMPLING_DIV_256;
}

/**
 * @brief  Initialize the ADCUI peripheral according to
 *         the specified parameters in the ADCUI_InitStruct.
 * @param  ADCUI_InitStruct: The pointer to a @ref ADCUI_InitTypeDef structure
 *         that contains the configuration information for the specified ADCUI peripheral.
 * @return None.
 */
void ADCUI_Init(const ADCUI_InitTypeDef* ADCUI_InitStruct)
{
    uint32_t TempCTRL1, TempFILTERCFG, TempCLKPHASE1;

    /* Check the parameters. */
    assert_param(IS_ADCUI_DATA_RESOL(ADCUI_InitStruct->ADCUI_DataResol));
    assert_param(IS_ADCUI_REFERENCE_VOLTAGE(ADCUI_InitStruct->ADCUI_VRefConfig));
    assert_param(IS_ADCUI_OSR_COF(ADCUI_InitStruct->ADCUI_Divider));
    assert_param(IS_ADCUI_CLK_FREQUENCY(ADCUI_InitStruct->ADCUI_ClockFrequency));
    assert_param(IS_ADCUI_CHOPPER_PERIOD(ADCUI_InitStruct->ADCUI_ChopperPeriod));
    assert_param(IS_ADCUI_CLK_OSR_VALID(ADCUI_InitStruct->ADCUI_ClockFrequency, ADCUI_InitStruct->ADCUI_Divider));

    /* Config the ADCUI control1 register. */
    TempCTRL1 = MDR_ADCUI->CTRL1 & ~(ADCUI_CTRL1_RESOL | ADCUI_CTRL1_VREF_SEL | ADCUI_CTRL1_OSR_CONF_Msk);

    TempCTRL1 |= ((uint32_t)ADCUI_InitStruct->ADCUI_DataResol) |
                 ((uint32_t)ADCUI_InitStruct->ADCUI_VRefConfig) |
                 ((uint32_t)ADCUI_InitStruct->ADCUI_Divider);

    /* Write to the ADCUI control1 register. */
    MDR_ADCUI->CTRL1 = TempCTRL1;

    /* Config the ADCUI FILTERCFG register. */
    TempFILTERCFG = MDR_ADCUI->FILTERCFG & ~ADCUI_FILTERCFG_CHP_ADC_CFG_Msk;
    TempFILTERCFG |= ((uint32_t)ADCUI_InitStruct->ADCUI_ChopperPeriod);

    /* Write to the ADCUI FILTERCFG register. */
    MDR_ADCUI->FILTERCFG = TempFILTERCFG;

    /* Config the ADCUI CLKPHASE1 register. */
    TempCLKPHASE1 = MDR_ADCUI->CLKPHASE1 & ~ADCUI_CLKPHASE1_CLC_ADC_CFG_Msk;
    TempCLKPHASE1 |= ((uint32_t)ADCUI_InitStruct->ADCUI_ClockFrequency);

    /* Write to the ADCUI CLKPHASE1 register. */
    MDR_ADCUI->CLKPHASE1 = TempCLKPHASE1;
}

/**
 * @brief  Reset the digital unit of the ADCUI blocks.
 * @param  NewState: @ref FunctionalState - a new state of the ADC digital unit.
 * @return None.
 */
void ADCUI_ResetDigital(FunctionalState NewState)
{
    assert_param(IS_FUNCTIONAL_STATE(NewState));

    if (NewState != DISABLE) {
        MDR_ADCUI->CTRL1 |= ADCUI_CTRL1_RESET_DIG;
    } else {
        MDR_ADCUI->CTRL1 &= ~ADCUI_CTRL1_RESET_DIG;
    }
}

/**
 * @brief Initialize the ADCUI Fx peripheral according to
 *        the specified parameters in the ADCUI_FxUnitInitStruct.
 * @param UnitNumber: @ref ADCUI_Unit_TypeDef - a number of the initialized channel.
 * @param ADCUI_FxUnitInitStruct: The pointer to a @ref ADCUI_FxUnit_InitTypeDef
 *        structure that contains the configuration information.
 * @return None.
 */
void ADCUI_Fx_Init(ADCUI_Unit_TypeDef UnitNumber, const ADCUI_FxUnit_InitTypeDef* ADCUI_FxUnitInitStruct)
{
    uint32_t TempFxCTR, TempCCALx, TempCCAL4;
    uint32_t TempF0AC   = 0;
    uint32_t TempMSC    = 0;
    uint32_t TempMSCMsk = 0;

    /* Check the parameters. */
    assert_param(IS_ADCUI_UNIT(UnitNumber));
    assert_param(IS_ADCUI_INT_STATE(ADCUI_FxUnitInitStruct->ADCUI_Fx_IntegratorEnable));
    assert_param(IS_ADCUI_INT_STATE(ADCUI_FxUnitInitStruct->ADCUI_F0_I3IntegratorEnable));
    assert_param(IS_ADCUI_IGAIN(ADCUI_FxUnitInitStruct->ADCUI_Fx_IGain));
    assert_param(IS_ADCUI_IGAIN(ADCUI_FxUnitInitStruct->ADCUI_F0_I3Gain));
    assert_param(IS_ADCUI_F0I3SEL_SELECT(ADCUI_FxUnitInitStruct->ADCUI_F0_I3SelectDataFilter));
    assert_param(IS_ADCUI_CCAL_GAIN(ADCUI_FxUnitInitStruct->ADCUI_Fx_IGainCalibration));
    assert_param(IS_ADCUI_CCAL_GAIN(ADCUI_FxUnitInitStruct->ADCUI_F0_I3GainCalibration));
    assert_param(IS_ADCUI_FxISEL_SELECT(ADCUI_FxUnitInitStruct->ADCUI_Fx_ISelectDataFilter));

    /* Configure main registers of the ADCUI Fx unit. */
    TempFxCTR = ((uint32_t)ADCUI_FxUnitInitStruct->ADCUI_Fx_IntegratorEnable << ADCUI_FxCTR_FxINTEN_Pos) |
                ((uint32_t)ADCUI_FxUnitInitStruct->ADCUI_Fx_IGain << ADCUI_FxCTR_FxIGAIN_Pos);

    TempCCALx = ((uint32_t)ADCUI_FxUnitInitStruct->ADCUI_Fx_IGainCalibration << ADCUI_CCALx_IxBGAIN_Pos);

    switch (UnitNumber) {
        case ADCUI_F0_UNIT:
            TempFxCTR |= ((uint32_t)ADCUI_FxUnitInitStruct->ADCUI_F0_I3IntegratorEnable << ADCUI_F0CTR_F0I3NTEN_Pos) |
                         ((uint32_t)ADCUI_FxUnitInitStruct->ADCUI_F0_I3Gain << ADCUI_F0CTR_F0I3GAIN_Pos);

            TempF0AC = ((uint32_t)ADCUI_FxUnitInitStruct->ADCUI_F0_I3SelectDataFilter);

            TempMSC    = ((uint32_t)ADCUI_FxUnitInitStruct->ADCUI_Fx_ISelectDataFilter << ADCUI_MSC_F0ISEL_HPF_Pos);
            TempMSCMsk = ADCUI_MSC_F0ISEL_HPF_Msk;

            TempCCAL4 = ((uint32_t)ADCUI_FxUnitInitStruct->ADCUI_F0_I3GainCalibration << ADCUI_CCAL4_I3BGAIN_Pos);
            break;

        case ADCUI_F1_UNIT:
            TempMSC    = ((uint32_t)ADCUI_FxUnitInitStruct->ADCUI_Fx_ISelectDataFilter << ADCUI_MSC_F1ISEL_HPF_Pos);
            TempMSCMsk = ADCUI_MSC_F1ISEL_HPF_Msk;
            break;

        case ADCUI_F2_UNIT:
            TempMSC    = ((uint32_t)ADCUI_FxUnitInitStruct->ADCUI_Fx_ISelectDataFilter << ADCUI_MSC_F2ISEL_HPF_Pos);
            TempMSCMsk = ADCUI_MSC_F2ISEL_HPF_Msk;
            break;
        default:
            break;
    }

    /* Write all main registers of the ADCUI Fx unit. */
    switch (UnitNumber) {
        case ADCUI_F0_UNIT:
            MDR_ADCUI->F0CTR = TempFxCTR;
            MDR_ADCUI->F0AC  = TempF0AC;
            MDR_ADCUI->CCAL1 = TempCCALx;
            MDR_ADCUI->CCAL4 = TempCCAL4;
            MDR_ADCUI->MSC   = (MDR_ADCUI->MSC & ~TempMSCMsk) | TempMSC;
            break;
        case ADCUI_F1_UNIT:
            MDR_ADCUI->F1CTR = TempFxCTR;
            MDR_ADCUI->CCAL2 = TempCCALx;
            MDR_ADCUI->MSC   = (MDR_ADCUI->MSC & ~TempMSCMsk) | TempMSC;
            break;
        case ADCUI_F2_UNIT:
            MDR_ADCUI->F2CTR = TempFxCTR;
            MDR_ADCUI->CCAL3 = TempCCALx;
            MDR_ADCUI->MSC   = (MDR_ADCUI->MSC & ~TempMSCMsk) | TempMSC;
            break;
        default:
            break;
    }
}

/**
 * @brief Fill each ADCUI_FxUnitInitStruct member with its default value.
 * @param ADCUI_FxUnitInitStruct: The pointer to a @ref ADCUI_FxUnit_InitTypeDef
 *        structure which is to be initialized.
 * @return None.
 */
void ADCUI_Fx_StructInit(ADCUI_FxUnit_InitTypeDef* ADCUI_FxUnitInitStruct)
{
    ADCUI_FxUnitInitStruct->ADCUI_Fx_IntegratorEnable   = ADCUI_INT_ENABLE;
    ADCUI_FxUnitInitStruct->ADCUI_F0_I3IntegratorEnable = ADCUI_INT_ENABLE;
    ADCUI_FxUnitInitStruct->ADCUI_Fx_IGain              = ADCUI_IGAIN_6dB;
    ADCUI_FxUnitInitStruct->ADCUI_F0_I3Gain             = ADCUI_IGAIN_6dB;
    ADCUI_FxUnitInitStruct->ADCUI_Fx_ISelectDataFilter  = ADCUI_FxISEL_BEFORE_HPF;
    ADCUI_FxUnitInitStruct->ADCUI_F0_I3SelectDataFilter = ADCUI_F0I3SEL_AFTER_HPF;
    ADCUI_FxUnitInitStruct->ADCUI_Fx_IGainCalibration   = 0;
    ADCUI_FxUnitInitStruct->ADCUI_F0_I3GainCalibration  = 0;
}

/**
 * @brief  ADCUI channel configuration.
 * @param  Channels: @ref ADCUI_Channel_TypeDef - specify the ADCUI channel to be enabled or disabled.
 * @param  NewState: @ref FunctionalState - the new states of the specified ADCUI channels.
 * @return None.
 */
void ADCUI_ChannelConfig(uint32_t Channels, FunctionalState NewState)
{
    /* Check the parameters. */
    assert_param(IS_ADCUI_CHANNELS(Channels));
    assert_param(IS_FUNCTIONAL_STATE(NewState));

    if (NewState != DISABLE) {
        MDR_ADCUI->CTRL1 |= Channels;
    } else {
        MDR_ADCUI->CTRL1 &= ~Channels;
    }
}

/**
 * @brief  Selecting DMA operating mode (single or block transactions).
 * @param  Channels: @ref ADCUI_Channel_TypeDef - specify the ADCUI channel to be enabled or disabled.
 * @param  Mode: @ref ADCUI_DmaTransMode_TypeDef - specify DMA transaction mode.
 * @param  NewState: @ref FunctionalState - the new states of the specified ADCUI channels when configuring the DMA operating mode.
 * @return None.
 */
void ADCUI_DMAConfig(uint32_t Channels, ADCUI_DmaTransMode_TypeDef Mode, FunctionalState NewState)
{
    /* Check the parameters. */
    assert_param(IS_ADCUI_CHANNELS(Channels));
    assert_param(IS_ADCUI_DMA_TRANSACTIONS_MODE(Mode));
    assert_param(IS_FUNCTIONAL_STATE(NewState));

    switch (Mode) {
        case ADCUI_DMA_TRANSACTIONS_SINGLE:
            if (NewState != DISABLE) {
                MDR_ADCUI->MSC |= (Channels << ADCUI_MSC_DMA_EN_RQ_S_Pos);
            } else {
                MDR_ADCUI->MSC &= (~Channels << ADCUI_MSC_DMA_EN_RQ_S_Pos);
            }
            break;
        case ADCUI_DMA_TRANSACTIONS_BLOCK:
            if (NewState != DISABLE) {
                MDR_ADCUI->MSC |= Channels;
            } else {
                MDR_ADCUI->MSC &= ~Channels;
            }
            break;
        default:
            break;
    }
}

/**
 * @brief  ADCUI chopper configuration.
 * @param  ChannelNumber: @ref ADCUI_Channel_TypeDef - specify the ADCUI channel in which you want to enable or disable the chopper.
 * @param  NewState: @ref FunctionalState - the new states of the specified ADCUI channels for working with chopper.
 * @return None.
 */
void ADCUI_ChopperConfig(ADCUI_Channel_TypeDef ChannelNumber, FunctionalState NewState)
{
    /* Check the parameters. */
    assert_param(IS_ADCUI_CHANNELS(ChannelNumber));
    assert_param(IS_FUNCTIONAL_STATE(NewState));

    if (NewState != DISABLE) {
        switch (ChannelNumber) {
            case ADCUI_CH_F0_I0:
                MDR_ADCUI->CTRL2 |= (1 << ADCUI_CTRL2_DCHPENI0_Pos);
                break;
            case ADCUI_CH_F1_I1:
                MDR_ADCUI->CTRL2 |= (1 << ADCUI_CTRL2_DCHPENI1_Pos);
                break;
            case ADCUI_CH_F2_I2:
                MDR_ADCUI->CTRL2 |= (1 << ADCUI_CTRL2_DCHPENI2_Pos);
                break;
            case ADCUI_CH_F0_I3:
                MDR_ADCUI->CTRL2 |= (1 << ADCUI_CTRL2_DCHPENI3_Pos);
                break;
            default:
                break;
        }
    } else {
        switch (ChannelNumber) {
            case ADCUI_CH_F0_I0:
                MDR_ADCUI->CTRL2 &= ~((uint32_t)1 << ADCUI_CTRL2_DCHPENI0_Pos);
                break;
            case ADCUI_CH_F1_I1:
                MDR_ADCUI->CTRL2 &= ~((uint32_t)1 << ADCUI_CTRL2_DCHPENI1_Pos);
                break;
            case ADCUI_CH_F2_I2:
                MDR_ADCUI->CTRL2 &= ~((uint32_t)1 << ADCUI_CTRL2_DCHPENI2_Pos);
                break;
            case ADCUI_CH_F0_I3:
                MDR_ADCUI->CTRL2 &= ~((uint32_t)1 << ADCUI_CTRL2_DCHPENI3_Pos);
                break;
            default:
                break;
        }
    }
}

/**
 * @brief  Return the result of the operation for the specified ADCUI channel.
 * @param  ChannelNumber: @ref ADCUI_Channel_TypeDef - ADCUI channel number.
 * @return A value of the ADCUI result register for the specified channel.
 */
uint32_t ADCUI_GetResult(ADCUI_Channel_TypeDef ChannelNumber)
{
    uint32_t ResultChannel = 0;

    /* Check the parameters. */
    assert_param(IS_ADCUI_CHANNEL(ChannelNumber));

    switch (ChannelNumber) {
        case ADCUI_CH_F0_I0:
            ResultChannel = MDR_ADCUI->F0I0DAT;
            break;
        case ADCUI_CH_F1_I1:
            ResultChannel = MDR_ADCUI->F1IDAT;
            break;
        case ADCUI_CH_F2_I2:
            ResultChannel = MDR_ADCUI->F2IDAT;
            break;
        case ADCUI_CH_F0_I3:
            ResultChannel = MDR_ADCUI->F0I3DAT;
            break;
        default:
            break;
    }
    return (ResultChannel);
}

/**
 * @brief  Reset certain flags in one of ADCUI units.
 * @param  UnitNumber: @ref ADCUI_Unit_TypeDef - select an ADCUI Fx unit.
 * @param  Flags: Specify the flags to clear.
 *         This parameter can be any combination of @ref ADCUI_Flags_TypeDef values.
 * @return None.
 */
void ADCUI_ClearFlags(ADCUI_Unit_TypeDef UnitNumber, uint32_t Flags)
{
    /* Check the parameters. */
    assert_param(IS_ADCUI_UNIT(UnitNumber));
    assert_param(IS_ADCUI_FLAG(Flags));

    switch (UnitNumber) {
        case ADCUI_F0_UNIT:
            MDR_ADCUI->F0STAT |= Flags;
            break;
        case ADCUI_F1_UNIT:
            MDR_ADCUI->F1STAT |= Flags;
            break;
        case ADCUI_F2_UNIT:
            MDR_ADCUI->F2STAT |= Flags;
            break;
        default:
            break;
    }
}

/**
 * @brief  Check whether a specified ADCUI flag is set or not.
 * @param  UnitNumber: @ref ADCUI_Unit_TypeDef - select an ADCUI Fx unit.
 * @param  ADCUI_Flag: @ref ADCUI_Flags_TypeDef - specify a flag to check.
 * @return @ref FlagStatus - a state of ADCUI flag (SET or RESET).
 */
FlagStatus ADCUI_GetFlagStatus(ADCUI_Unit_TypeDef UnitNumber, ADCUI_Flags_TypeDef ADCUI_Flag)
{
    FlagStatus Flag = RESET;

    /* Check the parameters. */
    assert_param(IS_ADCUI_UNIT(UnitNumber));
    assert_param(IS_ADCUI_FLAG(ADCUI_Flag));

    switch (UnitNumber) {

        case ADCUI_F0_UNIT:
            if ((MDR_ADCUI->F0STAT & (uint32_t)ADCUI_Flag) != 0) {
                Flag = SET;
            } else {
                Flag = RESET;
            }
            break;
        case ADCUI_F1_UNIT:
            if ((MDR_ADCUI->F1STAT & (uint32_t)ADCUI_Flag) != 0) {
                Flag = SET;
            } else {
                Flag = RESET;
            }
            break;
        case ADCUI_F2_UNIT:
            if ((MDR_ADCUI->F2STAT & (uint32_t)ADCUI_Flag) != 0) {
                Flag = SET;
            } else {
                Flag = RESET;
            }
            break;
        default:
            break;
    }
    return (Flag);
}

/**
 * @brief  Return a combined value of the ADCUI Fx unit status flags.
 * @param  UnitNumber: @ref ADCUI_Unit_TypeDef - select an ADCUI Fx unit.
 * @return A combined value of ADCUI status flags.
 */
uint32_t ADCUI_GetStatus(ADCUI_Unit_TypeDef UnitNumber)
{
    uint32_t StatusFlags = 0;

    /* Check the parameters. */
    assert_param(IS_ADCUI_UNIT(UnitNumber));

    switch (UnitNumber) {
        case ADCUI_F0_UNIT:
            StatusFlags = MDR_ADCUI->F0STAT & ADCUI_FLAGS_MASK;
            break;
        case ADCUI_F1_UNIT:
            StatusFlags = MDR_ADCUI->F1STAT & ADCUI_FLAGS_MASK;
            break;
        case ADCUI_F2_UNIT:
            StatusFlags = MDR_ADCUI->F2STAT & ADCUI_FLAGS_MASK;
            break;
        default:
            break;
    }
    return (StatusFlags);
}

/**
 * @brief  Enable or disable the ADCUI interrupts.
 * @param  UnitNumber: @ref ADCUI_Unit_TypeDef - select an ADCUI Fx unit.
 * @param  ADCUI_IT: Specify the ADCUI interrupt sources to be enabled or disabled.
 *         This parameter can be any combination of @ref ADCUI_IT_TypeDef vaues.
 * @param  NewState: @ref FunctionalState - a new state of the ADCUI interrupts.
 * @return None.
 */
void ADCUI_ITConfig(ADCUI_Unit_TypeDef UnitNumber, uint32_t ADCUI_IT, FunctionalState NewState)
{
    /* Check the parameters. */
    assert_param(IS_ADCUI_UNIT(UnitNumber));
    assert_param(IS_ADCUI_ITS(ADCUI_IT));
    assert_param(IS_FUNCTIONAL_STATE(NewState));

    /* Configure IT state. */
    switch (UnitNumber) {

        case ADCUI_F0_UNIT:
            if (NewState != DISABLE) {
                MDR_ADCUI->F0MASK |= ADCUI_IT;
            } else {
                MDR_ADCUI->F0MASK &= ~ADCUI_IT;
            }
            break;
        case ADCUI_F1_UNIT:
            if (NewState != DISABLE) {
                MDR_ADCUI->F1MASK |= ADCUI_IT;
            } else {
                MDR_ADCUI->F1MASK &= ~ADCUI_IT;
            }
            break;
        case ADCUI_F2_UNIT:
            if (NewState != DISABLE) {
                MDR_ADCUI->F2MASK |= ADCUI_IT;
            } else {
                MDR_ADCUI->F2MASK &= ~ADCUI_IT;
            }
            break;
        default:
            break;
    }
}

/** @} */ /* End of the group ADCUI_Exported_Functions */

/** @} */ /* End of the group ADCUI */

/** @} */ /* End of the group MDR12065_StdPeriph_Driver */

/*********************** (C) COPYRIGHT 2026 Milandr ****************************
 *
 * END OF FILE MDR12065_adcui.c */

